#include <string>
#include <list>
#include <string.h>

#define SERVER_PORT 		1688	/*server port*/
#define CLIENT_PORT 		7000	/*client local port*/

#define MAX_NAME_SIZE 		15

/*P2P server <-> client protocol*/
#define LOGIN 			1
#define LOGOUT 			2
#define GETALLUSER 		3
#define KEEPALIVE		4

/*P2P client <-> client protocol*/
#define P2P_PUNCH 		100
#define P2P_TRACKER_DATA	101


#define MAX_PACKET_SIZE 	2048



/*client node info*/
struct UserListNode
{
	char userName[MAX_NAME_SIZE];			/*client name*/
	unsigned int uiIP;				/*client ip*/
	unsigned short usPORT;				/*client udp port*/
	unsigned char alive_flag;
	
	UserListNode()
        {
            memset(this, 0, sizeof(*this));
        }
};

/*communication message struct*/
struct CommMsg
{
	unsigned int uiMsgType;				/*message type*/
	char cMyName[MAX_NAME_SIZE];			/*source client name*/	
	char cToName[MAX_NAME_SIZE];			/*target client name*/ 

	unsigned int   userNums;			/*client counts*/
	UserListNode userList[0];			/*user list*/

        CommMsg()
        {
            memset(this, 0, sizeof(*this));
        }
        
	unsigned int getSize() const { return sizeof(*this) + userNums * sizeof(UserListNode); }
};

using namespace std;
typedef list<UserListNode*> UserList;
